# @author zfd
# @date 2022年12月13日 11:46
# @desc 变量前面加 __ 标识封装起来不允许直接访问，但可通过类名访问
#

class Student:
    def __init__(self, name, age):
        self.name = name
        self.__age = age # 不允许在类的外部访问
    def show(self):
        print(self.name, self.__age)

stu1 = Student(name="zhangsang", age=10)
stu1.show()
print(stu1.name)
# print(stu1.__age) # AttributeError: 'Student' object has no attribute '__age
print('通过 dir  查看信息')
print(dir(stu1)) # age属性实际封装成了 '_Student__age'
print(stu1._Student__age) # AttributeError: 'Student' object has no